//
//  ZDotorFreshView.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/20.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZDotorFreshView.h"
#import "ZLabelTools.h"
@interface ZDotorFreshView () {
    UIImageView * _headView;
    UILabel * _nameLabel;
    UILabel * _ksLabel;
    UILabel * _levelLabel;
    UILabel * _hospitalLabel;
    UIButton * _dotorBtn;
}
@end
@implementation ZDotorFreshView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initlizeInterface];
    }
    return self;
}
- (void)initlizeInterface {
    [self makeSubView];
    [self addAllSubView];
    [self makeAllSubmasnoy];
}
- (void)makeSubView {
    _headView = [[UIImageView alloc] init];
    _headView.layer.cornerRadius = 17.5*xsIZE;
    _headView.layer.masksToBounds = YES;
    _nameLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_nameLabel Textcolor:KHGreenColor backColor:[UIColor clearColor] Fontsize:15 context:@"黄老板" isCenter:NO];
    _ksLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_ksLabel Textcolor:KHGaryColor backColor:[UIColor clearColor] Fontsize:13 context:@"神经科" isCenter:YES];
    _levelLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_levelLabel Textcolor:KHGaryColor backColor:[UIColor clearColor] Fontsize:13 context:@"主治医生" isCenter:NO];
    _hospitalLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_hospitalLabel Textcolor:KHGaryColor666 backColor:[UIColor clearColor] Fontsize:12 context:@"成都天府医院" isCenter:NO];
    _dotorBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_dotorBtn addTarget:self action:@selector(dotorBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
- (void)addAllSubView{
    [self addSubview:_headView];
    [self addSubview:_nameLabel];
    [self addSubview:_ksLabel];
    [self addSubview:_levelLabel];
    [self addSubview:_hospitalLabel];
    [self addSubview:_dotorBtn];
}
- (void)makeAllSubmasnoy {
    [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(10*xsIZE);
        make.height.offset(35*xsIZE);
        make.width.equalTo(_headView.mas_height);
        make.top.equalTo(self);
    }];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_headView.mas_right).offset(8*xsIZE);
        make.height.offset(15*ysIZE);
        make.width.offset(50*xsIZE);
        make.top.equalTo(_headView);
    }];
    [_ksLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_nameLabel);
        make.left.equalTo(_nameLabel.mas_right);
        make.width.offset(60*xsIZE);
        make.height.offset(13*ysIZE);
    }];
    [_levelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.height.equalTo(_ksLabel);
        make.left.equalTo(_ksLabel.mas_right);
        make.width.offset(60*xsIZE);
    }];
    [_hospitalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self);
        make.width.offset(120*xsIZE);
        make.height.offset(12*ysIZE);
        make.left.equalTo(_nameLabel);
    }];
    [_dotorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
}
- (void)dotorBtnAction {
    if (self.ZDFDelegate && [self.ZDFDelegate conformsToProtocol:@protocol(ZDotorFreshDeleGate)]) {
        [self.ZDFDelegate jumpDoctorViewController];
    }
}
- (void)setDoctorModel:(DoctorModel *)doctorModel {
    _doctorModel = doctorModel;
    _nameLabel.text = _doctorModel.name;
    _ksLabel.text = _doctorModel.office;
    _levelLabel.text = _doctorModel.job_title;
    _hospitalLabel.text = _doctorModel.hospital;
    NSString *iconStr = [NSString stringWithFormat:@"%@%@",IconURL,doctorModel.pic];
    [_headView sd_setImageWithURL:[NSURL URLWithString:iconStr] placeholderImage:[UIImage imageNamed:@""]];
}
@end
